package com.itheima.hmshopping.app.controller;

import com.itheima.hmshopping.app.service.UmsAdminService;


import com.itheima.hmshopping.dto.InfoDto;
import com.itheima.hmshopping.entity.UmsAdmin;
import com.itheima.hmshopping.util.R;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("admin")
public class UmsAdminController {
    @Autowired
    private UmsAdminService umsAdminService;

    /**
     * 登录,获取token
     * @param
     * @return
     */
    @PostMapping("/login")
    public R<Map> login(@RequestBody Map<String,String> map){
       return umsAdminService.login(map);

    }

    /**
     * 获取当前登录用户信息
     * @param name
     * @return
     */
    @GetMapping("/info")
    public R<InfoDto> info(String name){
        return umsAdminService.info(name);

    }

    /**
     * 登出
     * @param
     * @return
     */
    @PostMapping("/logout")
    public R logout(){
        return umsAdminService.logout();
    }

    /**
     * 刷新token
     * @param
     * @return
     */
    @GetMapping("/refreshToken")
    public R refreshToken(){
        return umsAdminService.refreshToken();
    }

    /**
     * 登出
     * @param
     * @return
     */
    @PostMapping("/register")
    public R register(@RequestBody UmsAdmin umsAdminParam){
        return umsAdminService.register(umsAdminParam);
    }

}
